<?php /* Smarty version 2.6.26, created on 2016-09-02 15:32:59
         compiled from head.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "../Common/head.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
		<div class="box">
			<button type="button" class="btn btn-info" data-toggle="modal" data-target=".bs-example-modal-sm">添加班级</button>
			<table class="table table-hover">
				<tr>
					<th>班级编号</th>
					<th>班级名称</th>
					<th>操作</th>
				</tr>
				<?php $_from = ($this->_tpl_vars['data']); if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['k'] => $this->_tpl_vars['v']):
?>
				<tr>
					<td><?php echo $this->_tpl_vars['v']['cid']; ?>
</td>
					<td><?php echo $this->_tpl_vars['v']['cname']; ?>
</td>
					<td>
						<a href="index.php?m=Admin&c=Stu&cid=<?php echo $this->_tpl_vars['v']['cid']; ?>
" class="btn btn-primary btn-xs">学生管理</a>
						<button onclick="edit(this,<?php echo $this->_tpl_vars['v']['cid']; ?>
)" cname="<?php echo $this->_tpl_vars['v']['cname']; ?>
" type="button" class="btn btn-success btn-xs" >编辑班级</button>
						<button onclick="del(<?php echo $this->_tpl_vars['v']['cid']; ?>
)" type="button" class="btn btn-danger btn-xs">删除班级</button>
					</td>
				</tr>
				<?php endforeach; endif; unset($_from); ?>
			</table>

		</div>
		<!--添加班级模态框-->
<form method="post" action="">		
		<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-sm">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
						<h4 class="modal-title">添加班级</h4>
					</div>
					<div class="modal-body">
						<div class="form-group">
							<label for="exampleInputEmail1">班级名称</label>
							<input type="text" name="cname" value="" required="" class="form-control" id="exampleInputEmail1" placeholder="请输入班级名称">
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
						<button type="submit" class="btn btn-primary">Save</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
</form>
<!--编辑班级模态框-->
<form method="post" action="index.php?m=Admin&a=edit">		
		<div class="modal fade editModel" id="edit" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-sm">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
						<h4 class="modal-title">编辑班级</h4>
					</div>
					<div class="modal-body">
						<div class="form-group">
							<label for="exampleInputEmail1">班级名称</label>
							<input type="text" name="cname" value="" required="" class="form-control" id="exampleInputEmail1" placeholder="请输入班级名称">
							<input type="hidden" name="cid" value=""/>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
						<button type="submit" class="btn btn-primary">Save</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
</form>
<!--删除模态框-->
<form method="post" action="index.php?m=Admin&a=del">
		<div class="modal fade delModel" id="del" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-sm">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
						<h4 class="modal-title">删除班级</h4>
					</div>
					<input type="hidden" name="cid" id="cid" value="" />
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
						<button type="submit" class="btn btn-primary">Save</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
	</body>

</html>
<script type="text/javascript">
	//编辑
	function edit(obj,cid)
	{
		//获取编辑班级名称（旧数据）
		var cname = $(obj).attr("cname");
		$("#edit").find("input[name=cname]").val(cname);
		$("#edit").find("input[type=hidden]").val(cid);
		//模态框显示
		$('#edit').modal('show')
	}
	//删除
	function del(cid)
	{
		$("#del").find("input[type=hidden]").val(cid);
		//模态框显示
		$('#del').modal('show')
	}
</script>